<script setup lang="jsx">
  import { generateRecord } from '@/api/software/generate';
  import dayjs from 'dayjs';
  const props = defineProps({
    bizKey: {
      type: String,
      default: '',
      required: true
    },
    flowKey: {
      type: String,
      default: '',
      required: true
    }
  });
  const tableData = ref([]);
  const runtimeRecordData = async () => {
    const params = {
      bizKey: props.bizKey,
      flowKey: props.flowKey
    };
    try {
      const { code, data } = await generateRecord(params);
      if (code === 200) {
        tableData.value = data;
      }
    } catch (error) {
      console.error(error, 'runtimeRecord');
    }
  };
  watchEffect(() => {
    runtimeRecordData();
  });
  const columns = [
    {
      label: '流程环节',
      prop: 'taskName'
    },
    {
      label: '执行结果',
      prop: 'ideaMsg'
    },
    {
      label: '执行人',
      prop: 'assigneeName'
    },
    {
      label: '执行时间',
      render: ({ row }) => {
        return <span>{row.time && dayjs(row.time).format('YYYY-MM-DD HH:mm:ss')}</span>;
      }
    }
  ];
</script>

<template>
  <NcTitle title="执行信息" type="center">
    <NcTable class="mt-20px" border :data="tableData" :columns="columns" />
  </NcTitle>
</template>

<style scoped lang="scss"></style>
